﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ATM.Entities;
using ATM.DAO;
using System.Data.SqlClient;

namespace ATM.BUS
{
    public class ChangePinBUS
    {
        public static bool CheckOldPin(string _cardID, string s)
        {
            Card card = CardDAO.GetCurrentCard(_cardID);
            return card.PIN == s;
        }

        public static int UpdatePIN(string _cardNo, string s)
        {
            if (s.Count() == 6)
            {
                SqlParameter[] para = new SqlParameter[2];
                para[0] = new SqlParameter("@CardNo", _cardNo);
                para[1] = new SqlParameter("@PIN", s);
                int k = CardDAO.ExecuteCommand("UpdatePin", para);
                return k;
            }
            return 0;
        }

    }
}
